//
//  YQTransferFootView.m
//  NewRetail
//
//  Created by yuqin on 2019/6/23.
//  Copyright © 2019年 yuqin. All rights reserved.
//

#import "YQTransferFootView.h"

@implementation YQTransferFootView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupBottomView];
    }
    return self;
}

- (void)setupBottomView {
    CGFloat backView_W = ScreenWidth/2.0-1;
    for (NSInteger i = 0; i < 2; i++) {

        NSDictionary *titleDict = @{@"1":@"收款",
                                    @"2":@"转账"
                                    };

        UIButton *bottomBtn = [YQViewFactory buttonWithTitle:[titleDict objectForKey:StringFromLongInt(i+1)] titleColor:WhiteColor fontSize:kNormalButtonFont userBold:NO target:self sel:@selector(bottomAction:)];
        bottomBtn.tag = 10+i;
        if (i == 0) {
            self.collectionBtn = bottomBtn;
            [bottomBtn setBackgroundColor:UIColorFromRGB(0x5884e1)];
        }else {
            self.transferBtn = bottomBtn;
            [bottomBtn setBackgroundColor:WhiteColor];
            [self.transferBtn setTitleColor:UIColorFromRGB(0x5884e1) forState:UIControlStateNormal];
        }
        
        [self addSubview:bottomBtn];
        [bottomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.left.mas_equalTo(backView_W*i);
            make.size.mas_equalTo(CGSizeMake(backView_W, FIT(50)));

        }];
    }
    
    

    //上面线
    UIView *topLineView = [[UIView alloc] init];
    topLineView.backgroundColor = UIColorFromRGB(0xeeeeee);
    [self addSubview:topLineView];
    [topLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(FIT(0));
        make.left.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, 1));
    }];
    
    //中间竖线
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = LineColor;
    [self addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.collectionBtn.mas_right).mas_equalTo(0);
        make.top.equalTo(topLineView.mas_bottom).mas_equalTo(FIT(5));
        make.size.mas_equalTo(CGSizeMake(1, FIT(40)));
    }];
    
}

- (void)bottomAction:(UIButton *)sender {
    if (self.SelectBlock) {
        self.SelectBlock(sender.tag-9);
    }
}

@end
